/* **********************************************************
 * Copyright 2010 Dimitar Vangelovski
 *
 * This file is part of the Gens3 3D Engine.
 * 
 * The Gens3 3D Engine is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 * 
 * The Gens3 3D Engine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with the Gens3 3D Engine; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA
 * **********************************************************/


#include "common.h"
#include "Scene.h"
#include "Material.h"
#include "LightObject.h"
#include "GeomObject.h"
#include "AnimObject.h"

CScene::CScene()
{
	m_strSceneFilename = "noname";
	m_nMaterialCount = 0;
	m_nGeomObjectCount = 0;
	m_nLightObjectCount = 0;
	m_Materials.clear();
	m_LightObjects.clear();
	m_GeomObjects.clear();
	m_AnimObjects.clear();
}

CScene::CScene(const CScene &other)
{
	m_strSceneFilename = other.GetSceneFilename();
	m_nMaterialCount = other.GetMaterialCount();
	m_nGeomObjectCount = other.GetGeomObjectCount();
	m_nLightObjectCount = other.GetLightObjectCount();
	m_Materials = other.GetMaterials();
	m_LightObjects = other.GetLightObjects();
	m_GeomObjects = other.GetGeomObjects();
	m_AnimObjects = other.GetAnimObjects();
}

CScene::CScene(std::string strSceneFilename, unsigned int nMaterialCount, unsigned int nGeomObjectCount, unsigned int nLightObjectCount)
{
	m_strSceneFilename = strSceneFilename;
	m_nMaterialCount = nMaterialCount;
	m_nGeomObjectCount = nGeomObjectCount;
	m_nLightObjectCount = nLightObjectCount;
	m_Materials.resize(m_nMaterialCount);
	m_LightObjects.resize(m_nLightObjectCount);
	m_GeomObjects.resize(m_nGeomObjectCount);
}

CScene::~CScene()
{
	for (unsigned int i = 0; i < m_nMaterialCount; i++)
	{
		delete m_Materials[i];
	}
	m_Materials.clear();

	for (unsigned int i = 0; i < m_nGeomObjectCount; i++)
	{
		delete m_GeomObjects[i];
	}
	m_GeomObjects.clear();

	for (unsigned int i = 0; i < m_nLightObjectCount; i++)
	{
		delete m_LightObjects[i];
	}
	m_LightObjects.clear();

	for (unsigned int i = 0; i < m_AnimObjects.size(); i++)
	{
		delete m_AnimObjects[i];
	}
	m_AnimObjects.clear();
}
